package personal.xjl._23java1studentdemo.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import personal.xjl._23java1studentdemo.mapper.CourseMapper;
import personal.xjl._23java1studentdemo.model.Course;
import personal.xjl._23java1studentdemo.service.CourseService;

import java.util.List;

@Service
public class CourseServiceImpl implements CourseService {

  @Autowired
    CourseMapper courseMapper;

    @Override
    public List<Course> findAll() {
        return courseMapper.selectAll();
    }

  @Override
  public int add(Course course) {
    return courseMapper.insert(course);
  }

  @Override
  public int remove(int id) {
    return courseMapper.delete(id);
  }

  @Override
  public Course findById(int id) {
    return courseMapper.findById(id);
  }

  @Override
  public int edit(Course course) {
    return courseMapper.update(course);
  }

  @Override
  public List<Course> findByPage(int pageNo, int pageSize) {
    return courseMapper.findByPage((pageNo-1)*pageSize, pageSize);
  }
}
